package org.bao.netcrawler.policy.model;

import java.util.ArrayList;

/**
 * 
 * one <b>Policy</b> object defines one website's URL and 
 * some key words to locate specified Strings in the URL's content. 
 * @author Bao<bb@feijiao.info>
 * @since 2010-12-24
 * @version 0.9.0
 * @license GPLv3
 */
public class Policy {
	private String format = null;
	private String url = null;
	private ArrayList<Target> targets = new ArrayList<Target>();
	
	
	public Policy(){
	//empty
	}

	public Policy(String format, String url){
		this.format = format;
		this.url = url;
	}
	
	public Policy(String format, String url, ArrayList<Target> targets){
		this.format = format;
		this.url = url;
		this.targets = targets;
	}
	
	
	public void addTarget(Target target){
		this.targets.add(target);
	}
	
	public void addTarget(String id, String position, String character){
		this.targets.add(new Target(id, position, character));
	}
	
	
	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public ArrayList<Target> getTargets() {
		return targets;
	}

	public void setTargets(ArrayList<Target> targets) {
		this.targets = targets;
	}
	
	public String toString(){
		return "[url = " + this.getUrl() + ", \ntargets = " + this.getTargets() + "]";
	}
}
